<?php

namespace app\admin\validate;
//TODO:删除use示例
use app\common\model\Config as ConfigModel;

class Menu extends AdminBase
{
    // 验证规则
    protected $rule =   [

        'name'  => 'require',
        'sort'  => 'require|number',
        'url'   => 'require|unique:menu',
        'component'   => 'require|unique:menu',
        'id'   => 'require'
    ];

    // 验证提示
    protected $message  =   [

        'name.require'    => '菜单名称不能为空',
        'sort.require'    => '排序值不能为空',
        'id.require'      => 'id不能为空',
        'url.require'     => 'url不能为空',
        'url.unique'      => 'url已存在',
        'component.require'     => '组件路径不能为空',
        'component.unique'      => '组件路径已存在',
        'sort.number'     => '排序值必须为数字',
    ];

    // 应用场景
    protected $scene = [

        'add'  =>  ['name', 'sort', 'url','component'],
        'edit' =>  ['name', 'sort','id'],
        'delete' =>  ['id'],
    ];

}